/**
 * Copyright (c) 2007,中企动力华南研发中心<br>
 * All rights reserved.<br>
 */
package com.ce.pms.system.renovation.web;

import java.util.List;

import com.ce.pms.base.web.PmsBaseAction;
import com.ce.pms.charge.model.BusinessCodeDomain;
import com.ce.pms.charge.service.IBusinessCodeService;
import com.ce.pms.charge.vo.BusinessCodeVO;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.exception.BusinessException;
import com.ce.pms.system.renovation.service.IReturnConfigService;
import com.sitechasia.webx.core.annotation.Read;

/**
 * 功能描述：<br>
 * @author 易贤建 创建日期：2009-1-4<br>
 */
public class ReturnConfigAction extends PmsBaseAction {

	/**
	 * 保证金退还设置
	 */
	private IReturnConfigService  returnConfigService = null;
	/**
	 * 交易码Service
	 */
	private IBusinessCodeService businessCodeService = null;
	/**
	 * 功能描述:初始化主页面<br>
	 * @return
	 * Create author:yixianjian <br>
	 * Create on:2009-1-4  <br>
	 */
	public String initMain(){
		try{
			init();
		}catch(BusinessException exception){
			exception.printStackTrace();
			String errorMessage = super.getLocaleMessage(exception.getMessage());
			setAttribute("errorMessage", errorMessage);
			return "error";
		}
		return "main";
	}
	/**
	 * 功能描述:更新参数<br>
	 * Create author:yixianjian <br>
	 * Create on:2009-1-4  <br>
	 */
	public String update(@Read SysrefcodeDO returnConfig,
			             @Read(key="deposit") Long depositKeyword){
		returnConfigService.editReturnconfig(returnConfig,depositKeyword);
		init();
		return "main";
	}
	private void init(){
		SysrefcodeDO returnConfig = returnConfigService.getSysrefcodeWithReturnconfig(); //
		BusinessCodeDomain depositPusinessCode = returnConfigService.getBizcodeWithDeposit();
		List<BusinessCodeVO> deposit =  businessCodeService.getAllIncomeBusinessCode();

		setAttribute("deposit", deposit);
		setAttribute("selectedDeposit", depositPusinessCode);
		setAttribute("returnConfig", returnConfig);

	}
	public void setReturnConfigService(IReturnConfigService returnConfigService) {
		this.returnConfigService = returnConfigService;
	}
	public void setBusinessCodeService(IBusinessCodeService businessCodeService) {
		this.businessCodeService = businessCodeService;
	}
}
